<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>物料计划系统</title>
    <script src="../static/jquery-3.6.3.min.js"></script>
    <link rel="stylesheet" href="../static/Layui_V2.5.6/layui/dist/css/layui.css">
    <script src="../static/layui/layui.js"></script>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        html {
            height: 100%;
        }

        body {
            height: 100%;
        }

        .container {
            height: 100%;
            background-image: linear-gradient(to right, #999999, #330867);
        }

        .login-wrapper {
            background-color: mediumpurple;
            width: 358px;
            height: 588px;
            border-radius: 15px;
            padding: 0 50px;
            position: relative;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
        }

        .header {
            font-size: 38px;
            font-weight: bold;
            text-align: center;
            line-height: 200px;
        }

        .input-item {
            display: block;
            width: 100%;
            margin-bottom: 20px;
            border: 0;
            padding: 10px;
            border-bottom: 1px solid rgb(128, 125, 125);
            font-size: 15px;
            outline: none;
        }

        .input-item::placeholder {
            text-transform: uppercase;
        }

        .btn {
            text-align: center;
            padding: 10px;
            width: 100%;
            margin-top: 40px;
            background-image: linear-gradient(to right, #a6c1ee, #fbc2eb);
            color: #fff;
            border: none;
        }

        .msg {
            text-align: center;
            line-height: 88px;
        }

        a {
            text-decoration-line: none;
            color: #abc1ee;
        }
    </style>
</head>
<body>
<div class="container">
    <div class="login-wrapper">
        <div class="header">Material Plan</div>
        <div class="form-wrapper">
            <input type="text" id="uname" name="username" placeholder="username" class="input-item">
            <input type="password" id="pwd" name="password" placeholder="password" class="input-item">
            <div class="btn" id="loginBtn">Login</div>
            <!--                <div class="btn" id="registerBtn">Login</div>-->
        </div>
        <div class="msg">
            Don't have account?
            Please Send Email To Administrator!
            <!--                <a href="#">Sign up</a>-->
        </div>
    </div>
</div>
<script>
    layui.use(["jquery", "layer"], function () {

        let href = window.location.href
        let frame = parent.document.getElementById("frame")
        if (frame !== undefined) {
            let src = $(frame).attr("src")
            if (src !== undefined && src !== "") {
                if (href.toString().includes("login") && !src.toString().includes("login")) {
                    window.parent.location.reload()
                }
            }
        }


        let layer = layui.layer;
        $("#loginBtn").click(function () {
            let uname = $("#uname").val()
            let pwd = $("#pwd").val()
            $.post("/login", {
                uname,
                pwd
            }, function (res) {
                if (res.code === 200) {
                    layer.msg(res.msg, {icon: 6, time: 1000}, function () {
                        window.location.href = "/"
                    })
                } else {
                    layer.msg(res.msg, {icon: 2, time: 2000}, function () {

                    })
                }
            })
        })
    })

</script>
</body>
</html>


